@use "theme/globals" as *;
:host {
    --toobar-background: var(--white);
    --button-color: var(--ion-text-color);
    --button-active-color: var(--gray-300);
    --background: var(--rte-editor-background);
}

:host-context(:root.dark) {
    --color: var(--white);
    --button-color: var(--gray-200);
    --button-active-color: var(--gray-500);
    --toobar-background: var(--gray-900);
}

:host {
    display: flex;
    flex-direction: column;
    background: var(--background);
    border: 2px solid var(--stroke);
    border-radius: var(--mdl-shape-borderRadius-md);
    flex-grow: 1;
    overflow: hidden;

    &.has-focus {
        border-color: var(--dark);
        outline: none !important;
    }

    .core-rte-editor, .core-textarea, textarea {
        outline: none !important;
    }

    .core-rte-editor-container {
        max-height: calc(100% - 46px);
        display: flex;
        flex-grow: 1;
        flex-direction: column;
        justify-content: space-between;
        &.toolbar-hidden {
            max-height: 100%;
        }
    }

    .core-rte-editor, .core-textarea {
        padding: 8px;
        margin: 2px;
        width: calc(100% - 4px);
        resize: none;
        background-color: var(--background);
        color: var(--color);
        flex-grow: 1;
    }

    .core-rte-editor {
        -webkit-user-select: auto !important;
        user-select: auto !important;
        word-wrap: break-word;
        overflow-x: hidden;
        overflow-y: auto;
        cursor: text;
        ::ng-deep img {
            @include padding(null, null, null, 2px);
            max-width: 95%;
            width: auto;
        }
        &.empty:before,
        &:empty:before {
            content: attr(data-placeholder-text);
            display: block;
            color: var(--placeholder-color);
            position: absolute;
            opacity: var(--placeholder-opacity);
            user-select: none;
        }

        // Make empty elements selectable (to move the cursor).
        ::ng-deep *:empty:after {
            content: '\200B';
        }
    }

    .core-textarea {
        position: relative;

        --full-highlight-height: 0px !important;

        ::ng-deep .textarea-wrapper {
            height: 100%;

            .textarea-wrapper-inner {
                height: 100%;
            }

            ::ng-deep textarea {
                caret-color: black;
                margin: 0px !important;
                padding: 0px;
                resize: none;
                overflow-x: hidden;
                overflow-y: auto;
                position: absolute;
                height: auto;
                top: 0px;
                bottom: 0px;
            }
        }
    }

    div.core-rte-toolbar {
        display: flex;
        width: 100%;
        z-index: 1;
        flex-grow: 0;
        flex-shrink: 0;
        background-color: var(--toobar-background);
        border-top: 1px solid var(--stroke);

        swiper-container {
            width: 240px;
            flex-grow: 1;
            flex-shrink: 1;
        }

        button {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 36px;
            height: 36px;
            padding-right: 6px;
            padding-left: 6px;
            margin: 2px auto;
            font-size: #{dynamic-font(18px)};
            background-color: var(--toobar-background);
            border-radius: var(--mdl-shape-borderRadius-xs);
            @include core-transition(background-color, 200ms);
            color: var(--button-color);
            cursor: pointer;

            &.toolbar-button-enable {
                width: 100%;
            }

            &:active, &[aria-pressed="true"] {
                background-color: var(--button-active-color);
            }

            &.toolbar-arrow {
                width: 28px;
                flex-grow: 0;
                flex-shrink: 0;
                opacity: 1;
                @include core-transition(opacity, 200ms);

                &:active {
                    background-color: var(--toobar-background);
                }

                &[disabled],
                &:disabled {
                    opacity: .5;
                }
            }
        }

        &.toolbar-hidden {
            visibility: hidden;
            height: 0;
            border: none;
        }
    }
}
